Skip to content

feat(remote): create or rotate an environment's engine key - #137

Merged
outofcoffee merged 2 commits into
mainfrom
feat/remote-external-api-key
Sep 3, 2026
Merged

feat(remote): create or rotate an environment's engine key#137
outofcoffee merged 2 commits into
mainfrom
feat/remote-external-api-key

Conversation

@outofcoffee

Copy link
Copy Markdown
Collaborator

Set an environment's engine key from the CLI, and resolve it for fleet routing.

Summary

  • outfit remote deploy --api-key-env VAR resolves the variable (process environment, then the .env beside the Outfit) and sends its value to the deploy, which creates the environment's key secret or rotates it. The reply carries only the action (created/rotated), never the value; a deploy with no flag leaves the stored key alone — generated only if absent, never regenerated.
  • fleet.yaml gains apiKeyEnv, the fleet-wide default variable holding a kind: remote node's engine key (a node's own engineTokenEnv still wins). A launch that cannot resolve it fails before the agent starts, rather than pointing it at a gate it cannot pass.
  • The key never lands anywhere it would persist: not in the deploy-config, the SSM parameter, the fleet file, or the logs.

Implementation details

  • The key is a property of the deploy request, the shape allowedCidr/reseed already set: it rides in the SigV4 body beside them with omitempty, so a control plane that predates it sees exactly the body it always saw.
  • The Lambda's ensureEnvApiKey is create-or-set — CreateSecret when the secret is absent, PutSecretValue when it exists (which invalidates the old key) — and distinguishes the two in its reply, since a first keyed deploy creates rather than rotates.
  • The Go client resolves the variable only after the Outfit's local environment has been applied, so an exported value wins and the .env fills a gap — the same precedence outfit uses everywhere.
  • The two surfaces stay independent: the deploy flag sets the secret, the fleet file names the variable that holds it. An operator who rotates a key via deploy must export the new value under the variable the fleet names; the fleet never guesses.

@outofcoffee outofcoffee added enhancement New feature or request go Pull requests that update go code labels Aug 25, 2026
@outofcoffee
outofcoffee force-pushed the feat/remote-external-api-key branch 2 times, most recently from bbbd569 to eeb4632 Compare September 2, 2026 00:29
outfit remote deploy --api-key-env VAR resolves the variable and sends its
value to the deploy, which creates the environment's key secret or rotates
it; the reply carries the action (created/rotated), never the value. A
deploy with no flag leaves the stored key alone.

fleet.yaml gains apiKeyEnv, the default variable holding a kind: remote
node's engine key (a node's own engineTokenEnv still wins), so a launch
resolves the key or fails before the agent starts.
@outofcoffee
outofcoffee merged commit 781504b into main Sep 3, 2026
3 checks passed
@outofcoffee
outofcoffee deleted the feat/remote-external-api-key branch September 3, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shared API key in fleet.yaml; remotes should accept an externally provided API key

1 participant